/**
 * Created by leo on 2019/12/22.
 */
$(".rule,.pop>button").click(function(){
    $(".mask").toggle();
});
var mySwiper = new Swiper ('.swiper-container', {
    direction: 'vertical',
    autoplay:true,
    loop : true,
    allowTouchMove: false,
});

function opt(r){
    console.log(r);
}


var width = $('.guagua').width() * 0.86;
var height = $('.guagua').height() * 0.64;

var img =[
    "../img/6.jpg",
    "../img/12.png",
];
var ram = randomNum(0,1);

function opt(b){
    var a = b * 100;
    if(a>=40){
        if(ram===0) {
            alert("中奖啦");
        }else{
            alert("谢谢参与")
        }
        return true;
    }
}
function randomNum(minNum,maxNum){
    switch(arguments.length){
        case 1:
            return parseInt(Math.random()*minNum+1,10);
            break;
        case 2:
            return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10);
            break;
        default:
            return 0;
            break;
    }
}
var canvas = ScratchMod({
    'container':$("#scratch_mod_container") , //目标容器
    'bgImgSrc': img[ram], //背景图
    'color':"#b0adb1" , //蒙版颜色（有imgSrc的情况下该属性无效）
    'width': width, //宽度
    'height': height, //高度
    'eraseRadius':40 , //擦除笔的半径(有penImgSrc的情况下无效)
    'sampleStep':40 , //获取擦除百分百时的精度（数字越大精度越小）
    'sampleCD':500 , //获取擦除百分百的时间间隔
    'sampleCallback':opt , //获取擦除百分百的回调函数（返回true后不再回调）,回调的第一个入参为擦除百分百
});
$(canvas).css({
    backgroundSize:"cover",
    backgroundPosition:"center",
});

